import request from "../utils/request";
import { Comment } from "@/types/comment";

export function getPlayListComment(params: {
  id: number | string;
  limit: number;
  offset: number;
}) {
  return request<{
    cnum: number;
    code: number;
    commentBanner: any;
    comments: Comment[];
    hotComments: Comment[];
    isMusician: boolean;
    more: boolean;
    topComments: Comment[];
    total: number;
    userId: number;
  }>({
    url: "/comment/playlist",
    params: {
      ...params,
      timestamp: Date.now(),
    },
  });
}

export function getSongComment(params: {
  id: number | string;
  limit: number;
  offset: number;
}) {
  return request<{
    cnum: number;
    code: number;
    commentBanner: any;
    comments: Comment[];
    hotComments: Comment[];
    isMusician: boolean;
    more: boolean;
    topComments: Comment[];
    total: number;
    userId: number;
  }>({
    url: "/comment/music",
    params: {
      ...params,
      timestamp: Date.now(),
    },
  });
}

export function getHotComment(params: {
  limit?: number;
  offset?: number;
  before?: number;
  id: number | string;
  type: number;
}) {
  return request<{
    code: number;
    hotComments: Comment[];
    total: number;
  }>({
    url: "/comment/hot",
    params,
  });
}

export function CDComment(params: {
  t: Number;
  type: Number;
  id: number | string;
  content?: string;
  commentId?: string | number;
}) {
  return request<{
    code: 200;
  }>({
    url: "/comment",
    method: "get",
    params,
  });
}
